package com.helloae.chap06;

import java.io.File;
import java.io.IOException;
import java.net.UnknownHostException;

import com.esri.arcgis.geodatabase.FeatureClassName;
import com.esri.arcgis.geodatabase.FeatureDataConverter;
import com.esri.arcgis.geodatabase.WorkspaceName;
import com.esri.arcgis.system.AoInitialize;
import com.esri.arcgis.system.EngineInitializer;
import com.esri.arcgis.system.esriLicenseProductCode;

/**
 * 创建一个Personal Geodatabase文件，并将Coverage中的图层插入其中<br>
 * 示例章节：6.4.1
 * @author light
 *
 */
public class CoverageToAccess {

	public static void main(String[] args) throws UnknownHostException, IOException {
		EngineInitializer.initializeEngine();
		AoInitialize ao = new AoInitialize();
		ao.initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);
		
		//读取输入文件
		String ecliseWorkspace = System.getenv("Eclipse3.6Workspace");
		WorkspaceName pInCovWorkspaceName = new WorkspaceName();
		pInCovWorkspaceName.setPathName(ecliseWorkspace+"HelloAE"+File.separator+"DataSet"+File.separator+"chap06");
		pInCovWorkspaceName.setWorkspaceFactoryProgID("esriDataSourcesFile.ArcInfoWorkspaceFactory");
		FeatureClassName pInFCName = new FeatureClassName();
		pInFCName.setName("breakstrm:arc");
		pInFCName.setWorkspaceNameByRef(pInCovWorkspaceName);
		
		//创建用于输出的IFeatureClassName并配置其所需的参数
		WorkspaceName pWorkspaceName = new WorkspaceName();
		pWorkspaceName.setWorkspaceFactoryProgID("esriDataSourcesGDB.AccessWorkspaceFactory");
		pWorkspaceName.setPathName("c:\\temp\\Trial.mdb");
		
		//在Personal Geodatabase中的图层名为breakstrm
		FeatureClassName pOutShFCName = new FeatureClassName();
		pOutShFCName.setWorkspaceNameByRef(pWorkspaceName);
		pOutShFCName.setName("breakstrm");
		
		//转换
		FeatureDataConverter pCovtoshape = new FeatureDataConverter();
		pCovtoshape.convertFeatureClass(pInFCName, null, null, pOutShFCName, null, null, "", 1000, 0);
		
		ao.shutdown();
		System.out.println("Congratulations!");
	}

}
